package com.gxa.user.redis.generateData;/**
 * @author JunYu
 * @create 2022-10-08--15:36
 */

import com.gxa.api.shop.entity.GoodIdAndNum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

/**
 * @program: take-out-project
 *
 * @description: 生成redis数据
 *
 * @author: JunYu
 *
 * @create: 2022-10-08 15:36
 **/
@Component
public class GoodNumGenerate {
    @Autowired
     RedisTemplate redisTemplate;

    public  void generateGoodNumGenerate(){
        GoodIdAndNum goodIdAndNum = new GoodIdAndNum();

        goodIdAndNum.setNum(10);

        Map<String,String> map = new HashMap<>();
        for(Integer i = 0 ; i < 10 ; i ++)
        {
            map.put(i.toString(),goodIdAndNum.getNum().toString());
        }
        redisTemplate.opsForHash().putAll("GoodIdAndNum",map);
    }
}
